import network from '../../utils/network.js';
//获取应用实例
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    select: false,
    tihuoWay: '2018',
    tihuoyue: '9',
    userInfo: [],
    isHiddenToast: true,
    page: 1,
    rows: 10,
    total: 0,
    hasMoreData: true,
    list: [],
    //当前选中导航的Inx值
    Inx: 0

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    const id = options.id;
    that.setData({
      pid: id,
    });
    that.getSale_list('正在加载数据...')
  },

//1
  bindShowMsg() {
    this.setData({
      select: !this.data.select
    })
  },
  mySelect(e) {
    var name = e.currentTarget.dataset.name
    this.setData({
      tihuoWay: name,
      select: false
    })
  },


// 2
  bindShowyue() {
    this.setData({
      select1: !this.data.select1
    })
  },
  mySelect1(e) {
    var name = e.currentTarget.dataset.name
    this.setData({
      tihuoyue: name,
      select1: false
    })
  },


  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
      if (res.from === 'button') {
        // 来自页面内转发按钮
        console.log(res.target)
      }
      return {
        title: '自定义转发标题',
        path: '/page/user?id=123'
      } 
  },

  /**
   * 获取订单列表
   */
  getSale_list: function (message) {
    var that = this;
    const pid = that.data.pid;
    var datas = that.data;
    var data = {
      uid: pid,
      ischeck: 1,
      page: datas.page,
      rows: datas.rows
    };
    network.requestLoading('http://jbc.com/System/Order/order_list', data, message, function (res) {
      var contentlistTem = that.data.list;
      if (res.code > 0) {
        if (contentlistTem.length < res.data.total) {
          that.setData({
            page: datas.page + 1,
            list: res.data.list,
          });
        } else {
          that.setData({
            hasMoreData: false
          });
        }

      } else {
        wx.showToast({
          title: res.msg,
        })
      }
    }, function (res) {
      wx.showToast({
        title: '加载数据失败',
      })

    })
  },
})
